package com.tiancheng.trade.order.service;

import com.tiancheng.trade.commom.core.exception.BusinessException;
import com.tiancheng.trade.order.bo.CouponBO;
import com.tiancheng.trade.order.model.Coupon;

import java.util.List;

/**
 * @Auther: ld
 * @Date: 2024/2/28 17:05
 * @Param ${tags}
 * @Description:
 */
public interface CouponService {

    /**
     * 锁定优惠券
     *
     * @param couponBOS
     * @throws BusinessException
     */
    List<CouponBO> lock(List<CouponBO> couponBOS) throws BusinessException;

    /**
     * 解锁优惠券
     *
     * @param couponBOS
     */
    void unlock(List<CouponBO> couponBOS);

    /**
     * 解锁优惠券
     *
     * @param uid
     * @param orderIds
     * @param subOrderIds
     * @throws BusinessException
     */
    void unlock(String uid, String[] orderIds, String[] subOrderIds) throws BusinessException;

    /**
     * 创建优惠券记录
     *
     * @param couponBOS
     * @return
     * @throws BusinessException
     */
    int create(List<CouponBO> couponBOS) throws BusinessException;

    /**
     * 核销优惠券
     *
     * @param uid
     * @param orderIds
     * @param subOrderIds
     * @throws BusinessException
     */
    void writeOff(String uid, String[] orderIds, String[] subOrderIds) throws BusinessException;

    /**
     * 查询订单的优惠券信息
     *
     * @param orderIds
     * @return
     */
    List<Coupon> find(String[] orderIds);

    /**
     * 获取主订单号优惠
     *
     * @param orderId
     * @return
     */
    List<Coupon> getCouponList(String orderId);

    /**
     * 获取子订单号优惠
     *
     * @param subOrderId
     * @return
     */
    List<Coupon> getSubCouponList(String subOrderId);

    /**
     * 获取主订单号优惠
     *
     * @param orderIds
     * @return
     */
    List<Coupon> getCouponByOrderId(List<String> orderIds);
    /**
     * 退还优惠券
     *
     * @param uid
     * @param orderIds
     * @param subOrderIds
     * @throws BusinessException
     */
    void returnCoupon(String uid, String[] orderIds, String[] subOrderIds) throws BusinessException;

}
